<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import = "java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver");

String url;
Connection conn;
ResultSet rs;
Statement stmt;

try 
{
	Class.forName("com.mysql.jdbc.Driver");
	url = "jdbc:mysql://localhost/inventory";
	conn = DriverManager.getConnection(url, "root", "root");
	
	stmt = conn.createStatement();
	rs = stmt.executeQuery("Select category_code from category");
%>
    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Online Inventory System - Add Item</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
		<div id="outer">
			<div id="wrapper">
			<div id="nav">
		<div id="nav-left">
		<div id="nav-right">
		<ul>
			<li><a href=index.jsp>Home</a></li>
			<li><a href=InventoryList>List Items</a></li>
            <li><a href=addItem.jsp>Add New Item</a></li>
			<li><a href=CategoryList>List Categories</a></li>
            <li><a href=addCategory.jsp>Add New Category</a></li>
        </ul>
		</div>
		</div>
		<div class="clear"></div>
		</div>
		<div id="head-2"></div>
		<div id="login">
		<div id="login-bot">

<form method = "post" action="AddItem">

<div class="ibm-column ibm-first">
<div class="ibm-container">
<h2 class="ibm-second">Add New Item</h2>
<div class="ibm-container-body">
<div class="fm-opt1">
<label>Item Code:</label><input type = "text" name = "itemCode">
</div>
<div class="fm-opt1">
<label>Item Name:</label><input type = "text" name = "itemName">
</div>
<div class="fm-opt1">
<label>Item Detail:</label><input type = "text" name = "itemDetail">
</div>
<div class="fm-opt1">
<label>Category Code:</label>
<%
out.println("<SELECT name=categoryCode>");
while (rs.next()){
out.println("<OPTION>" + rs.getObject(1).toString() + "</OPTION>");
}
out.println("</SELECT>");
}
catch(ClassNotFoundException e)
{
	out.println("" + e);
}
catch (SQLException e)
{
	out.println("" + e);
}
%>

</div>
<div class="fm-opt1">
<label>Item Quantity:</label><input type = "text" name = "itemQuantity">
</div>
<input type = "submit">
</form>


</div>
</div>
</div>
</div>
</body>
</html>